package com.jiaai.cloud.system.service.impl;

import com.jiaai.cloud.base.util.RandomUtils;
import com.jiaai.cloud.system.entity.TLiveServer;
import com.jiaai.cloud.system.mapper.TLiveServerMapper;
import com.jiaai.cloud.system.service.ITLiveServerService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 直播推流服务器 服务实现类
 * </p>
 *
 * @author 佳爱网络科技
 * @since 2017-08-01
 */
@Service
public class TLiveServerServiceImpl extends ServiceImpl<TLiveServerMapper, TLiveServer> implements ITLiveServerService {

    @Override
    public String getLiveUrl() {
        List<TLiveServer> liveServers=baseMapper.selectList(null);
        TLiveServer liveServer=liveServers.get(RandomUtils.nextInt(liveServers.size()));

        return "rtmp://"+liveServer.getAddress()+":"+liveServer.getPort();
    }
}
